package com.zzx.boot.controller;

import com.zzx.boot.servlet.TopicClassService;
import com.zzx.boot.servlet.TopicService;
import com.zzx.boot.utils.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author tan
 * @version 1.0
 * @date 2023/7/8 14:45
 */
@Api(tags = "话题模块")
@RestController
@RequiredArgsConstructor
@RequestMapping("/topic")
public class TopicController {

    private final TopicClassService topicClassService;
    private final TopicService topicService;

    @ApiOperation(value = "话题分类")
    @GetMapping("/class")
    public R getTopicClass(){
        return topicClassService.getTopicClass();
    }

    @ApiOperation("获取热门话题")
    @GetMapping("/hot/topic")
    public R hotTopic(){
        return topicService.hotTopic();
    }

    @ApiOperation("获取话题分类下的话题")
    @GetMapping("/topicclass/{classId}/topic/{current}")
    public R topicByTopicClass(@PathVariable("classId") Long classId, @PathVariable("current") Integer current){
        return topicService.topicByTopicClass(classId,current);
    }

    @ApiOperation("搜索话题")
    @GetMapping("/search/page/{current}")
    public R topicSearch(String keyword,@PathVariable("current") Long current){
        return R.success(topicService.topicSearch(keyword,current));
    }


}
